package pers.xx.sbm.controller;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.xx.sbm.entity.OptLog;
import pers.xx.sbm.entity.OptLogDetail;
import pers.xx.sbm.enums.ResultEnum;
import pers.xx.sbm.service.OptLogDetailService;
import pers.xx.sbm.service.OptLogService;
import pers.xx.sbm.vo.ResResult;

/**
 * @author ：xiexing
 * @description ： 操作日志controller
 * @date ： 2020/8/11 10:40
 */
@Controller
@RequestMapping("/optLog")
public class OptLogController {

    @Autowired
    OptLogService optLogService;

    @Autowired
    OptLogDetailService optLogDetailService;


    /**
     * @description 操作日志
     * @author XieXing
     * @date 2020/8/11 15:45
     */
    @RequestMapping("/log")
    public String optLogPage(Model model) {
        return "page/operation/opt_log";
    }

    /**
     * @description 获取日志列表
     * @author XieXing
     * @date 2020/8/16 12:02
     */
    @RequestMapping("/getOptLogList")
    @ResponseBody
    public ResResult<PageInfo> getSystemList(OptLog optLog, Integer page, Integer limit) {
        ResResult resResult = optLogService.listByPage(optLog, page, limit);
        resResult.setOptName("获取操作日志列表");
        return resResult;
    }

    /**
     * @description 获取日志列表
     * @author XieXing
     * @date 2020/8/16 12:02
     */
    @RequestMapping("/getOptLogDetail")
    @ResponseBody
    public ResResult<PageInfo> getSystemList(Integer optId) {
        OptLogDetail optLogDetail = optLogDetailService.selectByPrimaryKey(optId);
        ResResult resResult = new ResResult(ResultEnum.SUCCESS, optLogDetail);
        resResult.setOptName("获取操作日志详情");
        return resResult;
    }

}
